﻿using System;
using System.Windows;
using System.Windows.Controls;
using GameLogic.Controls;
using GameLogic.Logic;

namespace TestUi.Content
{
	public partial class CollisionTypeGame : UserControl, IGameFeatures
	{
        GameLoop gameLoop;
        
        // IGameFeatures event handlers
        public event EventHandler<ScoresChangedEventArgs> ChangeScoresFired;
        public event EventHandler<LivesChangedEventArgs> ChangeLivesFired;
        //public event EventHandler<HighscoreEntryArgs> HighscoreEntryFired;
        //public event EventHandler PauseTimerFired;
        //public event EventHandler ResumeTimerFired;
        public event EventHandler GameOverFired;
        //public event EventHandler NewGameFired;


        public CollisionTypeGame()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(OnLoaded);
        }

        void OnLoaded(object sender, RoutedEventArgs e)
        {
            // Find the GameLoop
            GameLoopFinder glf = new GameLoopFinder(LayoutRoot);
            gameLoop = glf.GameLoop;
        }

        #region IGameFeatures Methods
        public void Start()
        {
            if (gameLoop != null)
                gameLoop.StartGameLoop();
        }

        public void Stop()
        {
            if (gameLoop != null)
                gameLoop.ResetGameLoop();
        }

        public void Pause()
        {
            if (gameLoop != null)
                gameLoop.PauseGameLoop();
        }

        public void Resume()
        {
            if (gameLoop != null)
                gameLoop.StartGameLoop();
        }

        //public void ChangeScores(int inc)
        //{

        //}

        //public void ChangeLives(int inc)
        //{

        //}

        //public void GameOver(GameOverEventArgs args)
        //{

        //}

        public bool IsTimeBased
        {
            get { return true; }
        }

        public bool IsLifeBased
        {
            get { return true; }
        }

        public string GameName
        {
            get { return "Test UI"; }
        }


        #endregion


        public TimeSpan GameDuration
        {
            get { throw new NotImplementedException(); }
        }
    }
}